package utils

import (
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
)



var (
	ErrMethodNotAllowed =NewErr(errors.New("requests methond not allowed"),http.StatusBadRequest)
	ErrRouteIsExist = NewErr(errors.New("route is exist,please use another"),http.StatusBadRequest)
	ErrUuidNotExist = NewErr(errors.New("uuid not exist,please use another"),http.StatusNotFound)
	ErrRouteNotExist = NewErr(errors.New("route is not exist"),http.StatusNotFound)

	)

func NewErr(err error,httpCode int)[]byte  {
	 msg:=ErrorMsg{Code:httpCode,  ErrMsg:err.Error()}
	 bytes,err:=json.Marshal(msg)
	 if err!=nil{
	 	fmt.Println(err)
	 }
	 return bytes
}
type ErrorMsg struct {
	Code int
	ErrMsg string
}